package com.kabuda.zhugehot200_review;

/**
 * @author kabuda
 * @date 2025-03-27 22:41
 * @description
 */
public class pow {
    public static void main(String[] args) {
        System.out.println(myPow(2, -2));
    }


    public static double myPow(double x, int n) {
        if (n == 0) { return 1; }
        if (n == 1) { return x; }
        if (n == -1) { return 1 / x; }
        double half = myPow(x, n / 2);
        double rest = myPow(x, n % 2);
        return rest * half * half;
    }

}
